<form id="<?php echo $uniqid;?>" method="post" style="padding: 8px;">
    <input type="hidden" name="id" value="<?php echo $dataset['id'];?>"/>
    <table border="0" width="100%" cellspacing="1" cellpadding="5" class="formtable">
        <tr bgcolor="#FFFFFF">
            <td class="tlabel"  width="10%">公司名称：</td>
            <td colspan="3"><input type="text" style="width: 330px;"
                                   class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                                   placeholder="请输入公司名称.." required="true" v-model="params.name"></td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel"  width="10%">主账号：</td>
            <td width="40%"><input name="phone" type="text"
                                   class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                                   placeholder="请输入电话.." required="true" v-model="params.phone"></td>
            <td class="tlabel"  width="10%">登陆密码：</td>
            <td width="40%"><input name="password" type="text" class="forminput inputstyle validatebox-text textbox-prompt"
                                   placeholder="请输入登陆密码.."  v-model="params.password"></td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="10%" class="tlabel" >联系人：</td>
            <td width="40%"><input type="text" style="width: 100px;"
                                   class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                                   placeholder="请输入姓名.."  v-model="params.contact">
            </td>
            <td width="10%" class="tlabel"  width="10%">联系电话：</td>
            <td width="40%"><input name="password" type="text" class="forminput inputstyle validatebox-text textbox-prompt"
                                   placeholder="联系电话.."  v-model="params.tel"></td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel" >状态：</td>
            <td>
                <label><input name="status" type="checkbox" class="textbox-prompt" v-model="params.status">激活</label></td>
            </td>
            <td class="tlabel" >排序：</td>
            <td><input name="sortorder" type="text"
                       class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                       placeholder="请输入排序.." v-model="params.sortorder"></td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel" >地址：</td>
            <td colspan="3"><input name="address" type="text" style="width: 561px;"
                                   class="forminput inputstyle validatebox-text easyui-validatebox"
                                   placeholder="请输入地址.." v-model="params.address"></td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel" >经度lng：</td>
            <td><label><input  type="text" class="forminput inputstyle textbox-prompt" v-model="params.lng"></label></td></td>
            <td class="tlabel" >纬度lat：</td>
            <td><label><input  type="text" class="forminput inputstyle textbox-prompt" v-model="params.lat"></label></td></td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel" >备注：</td>
            <td colspan="3" style="padding-top: 5px;"><textarea name="remark" style="width: 545px;height: 70px; padding: 8px;" v-model="params.remark"
                                                                 class="formarea validatebox-text textbox-prompt easyui-validatebox"
                                                                 placeholder="请输入备注.."></textarea></td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel" >Logo图片：</td>
            <td colspan="3" style="padding-left: 0;">
                <div title="上传图片">
                    <div class="col-md-12">
                        <div id="container" style="background-color:#F9F9F4">
                            <a class="btn btn-default btn-lg" id="companylogoPickfile<?php echo $uniqid;?>" href="#" style="text-decoration: none;">
                                <div style="padding:20px;"><i class="iconfont icon-xiangji"></i> 点击上传图片...</div>
                            </a>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <table id="uploadtable" class="formtable" id="fsUploadProgressTable1">
                            <tbody id="fsUploadProgress">
                            <template v-if="params.logo">
                                <tr class="progressContainer" style="opacity: 1;">
                                    <td class="progressName">
                                        <div class="gallery"><a class="linkWrapper" target="_blank" :href="params.logo" title="查看原图">
                                            <img style="width: 80px" :src="params.logo+'?imageView2/1/w/100/h/100'">
                                        </a></div>
                                    </td>
                                    <td>
                                        <div class="info" style="display: flex">
                                            <div style="flex: 4"><span>{{params.logo}}</span></div>
                                            <div style="flex: 1">
                                                <input class='l-btn l-btn-small btn-del' @click="rm()" value="删除图片" type="button">
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            </template>
                            </tbody>
                        </table>
                    </div>
                </div>
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel" >轮播图：</td>
            <td colspan="3" style="padding-left: 0;">
                <div title="上传图片">
                    <div class="col-md-12">
                        <div id="swiper" style="background-color:#F9F9F4">
                            <a class="btn btn-default btn-lg" id="companyswiperPickfiles<?php echo $uniqid;?>" href="#" style="text-decoration: none;">
                                <div style="padding:20px;"><i class="iconfont icon-xiangji"></i> 点击上传图片...</div>
                            </a>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <table class="formtable">
                            <tbody>
                            <template v-for="(vo,index) in images">
                                <tr style="opacity: 1;">
                                    <td class="progressName">
                                        <div class="gallery"><a class="linkWrapper" target="_blank" :href="vo" title="查看原图">
                                            <img style="width: 80px" :src="vo+'?imageView2/1/w/100/h/100'">
                                        </a></div>
                                    </td>
                                    <td>
                                        <div class="info" style="display: flex">
                                            <div style="flex: 4"><span>{{vo}}</span></div>
                                            <div style="flex: 1">
                                                <input class='l-btn l-btn-small btn-del' @click="rmswiper(index)" value="删除图片" type="button">
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            </template>
                            </tbody>
                        </table>
                    </div>
                </div>
            </td>
        </tr>
    </table>
</form>

<script>
    var companyaddVm = new Vue({
        el: '#<?php echo $uniqid;?>',
        data: {
            params: {},
            images: []
        },
        methods: {
            submit: function () {
                companyaddVm.params.images = companyaddVm.images.join(',');
                $.post('/admin/company/add', companyaddVm.params, function (data) {
                    if (data.ret == 0) {
                        $.messager.show({
                            title: '提示',
                            msg: data.msg,
                            timeout: 3000,
                            showType: 'slide'
                        });
                        $('#<?php echo $uniqid;?>').form('clear');
                        $("#companydlg").dialog('close');
                        $("#company").datagrid('reload');
                    } else {
                        $.messager.alert('提示', data.msg, 'warning');
                    }
                }, 'json');
            },
            rm() {
                $.messager.confirm('确认对话框', '您确认删除么？', function (r) {
                    if (r) {
                        companyaddVm.params.logo = '';
                    }
                });
            },
            rmswiper(index) {
                $.messager.confirm('确认对话框', '您确认删除么？', function (r) {
                    if (r) {
                        companyaddVm.images.splice(index, 1);
                    }
                });
            }
        }
    });
    $(function () {
        $('#companyaddsubmit').click(function (data) {
            companyaddVm.submit();
        });
        qiniu_single('companylogoPickfile<?php echo $uniqid;?>', function (res) {
            companyeditVm.params.logo = '';
            companyeditVm.params.logo = res;
        });
        qiniu_multiple('companyswiperPickfiles<?php echo $uniqid;?>', function (res) {
            companyeditVm.images.push(res);
        });
    });
</script>
